<div
    bsModal
    #createOrEditModal="bs-modal"
    class="modal fade"
    tabindex="-1"
    role="dialog"
    aria-labelledby="createOrEditModal"
    aria-hidden="true"
    [config]="{ backdrop: 'static' }"
>
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <form
                *ngIf="active"
                #editForm="ngForm"
                novalidate
                (ngSubmit)="save()"
                autocomplete="off"
            >
                <div class="modal-header">
                    <h4 class="modal-title">
                        <span>车位租赁</span>
                    </h4>
                    <button
                        type="button"
                        class="close"
                        (click)="close()"
                        [attr.aria-label]="l('Close')"
                    >
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <p-toggleButton
                        [(ngModel)]="checked2"
                        onLabel="出租"
                        offLabel="购买"
                        [ngModelOptions]="{ standalone: true }"
                        [style]="{ width: '150px' }"
                        (onChange)="setEndTime()"
                    ></p-toggleButton>
                    <div class="form-group" *ngIf="checked2">
                        <label for="toolType">付款类型 *</label>
                        <div class="row" style="margin: 0">
                            <div class="col-md-12" style="padding-left: 0">                                
                                <select
                                    id="toolType"
                                    #toolTypeCombobox="ngModel"
                                    name="toolType"
                                    class="form-control"
                                    [(ngModel)]="payTypeDisplayText"                                    
                                    required
                                    (change)="payTypeChange($event.target)"
                                >
                                    <option value="">{{ emptyText }}</option>
                                    <option
                                        *ngFor="let payType of payTypes"
                                        [value]="payType.displayText"
                                    >
                                        {{ payType.displayText }}
                                    </option>
                                </select>
                                <validation-messages
                                    [formCtrl]="toolTypeCombobox"
                                ></validation-messages>
                            </div>

                            <div class="col-md-12" style="padding-left: 0">
                                <label for="payvalue">金额 *</label>
                                <input
                                    id="payvalue"
                                    #displayNameInput = "ngModel"
                                    type="text"
                                    name="payvalue"
                                    class="form-control"
                                    [ngModel]="payvalue"
                                    disabled
                                    required
                                />
                                <validation-messages
                                    [formCtrl]="displayNameInput"
                                ></validation-messages>
                            </div>
                        </div>
                    </div>
                    <div class="form-group" *ngIf="!checked2">
                        <label for="equipName">购买金额 *</label>
                        <div class="row" style="margin: 0">
                            <div class="col-md-12" style="padding-left: 0">
                                <input
                                    id="SellingPrice"
                                    #displayNameInput="ngModel"
                                    type="text"
                                    name="SellingPrice"
                                    class="form-control"
                                    [(ngModel)]="SellingPrice"
                                    disabled="disabled"
                                    required
                                />
                                <validation-messages
                                    [formCtrl]="displayNameInput"
                                ></validation-messages>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="equipName">车位选择 *</label>
                        <div class="row" style="margin: 0">
                            <div class="col-md-12" style="padding-left: 0">
                                <select
                                    id="placeid"
                                    #displayNameInput="ngModel"
                                    name="placeid"
                                    class="form-control"
                                    [(ngModel)]="placeid"
                                    [attr.data-live-search]="true"
                                    jq-plugin="selectpicker"
                                    required
                                    minlength="1"
                                >
                                    <option value="">{{ emptyText }}</option>
                                    <option
                                        *ngFor="let place of places"
                                        [value]="place.value"
                                    >
                                        {{ place.displayText }}
                                    </option>
                                </select>
                                <validation-messages
                                    [formCtrl]="displayNameInput"
                                ></validation-messages>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="equipName">起止日期  *</label>
                        <div class="row" style="margin: 0">
                            <div class="col-md-12" style="padding-left: 0">
                                <p-calendar name="startDate" 
                                    [(ngModel)]="startDate" 
                                    [locale]="ch" 
                                    dateFormat="yy-mm-dd"                                   
                                    showButtonBar="true"
                                    [readonlyInput]="true"
                                    (onSelect)="setEndTime()"
                                    required
                                ></p-calendar>~
                                <p-calendar name="endDate" 
                                    [(ngModel)]="endDate" 
                                    [locale]="ch" 
                                    dateFormat="yy-mm-dd"                                   
                                    disabled="true"
                                ></p-calendar>
                            </div>
                        </div>
                    </div>
                    <p-toggleButton
                        [(ngModel)]="checked"
                        onLabel="增加车辆"
                        offLabel="无车辆"
                        onIcon="pi-check"
                        offIcon="pi pi-times"
                        [ngModelOptions]="{ standalone: true }"
                        [style]="{ width: '150px' }"
                    ></p-toggleButton>
                    <div class="row" style="margin: 0" *ngIf="checked">
                        <div class="col-md-12" style="padding-left: 0">
                            <label for="payvalue">车牌 *</label>
                            <input
                                id="carNum"
                                #displayNameInput="ngModel"
                                type="text"
                                name="carNum"
                                class="form-control"
                                [(ngModel)]="carNum"
                                required
                            />
                            <validation-messages
                                [formCtrl]="displayNameInput"
                            ></validation-messages>
                        </div>
                        <div class="col-md-12" style="padding-left: 0">
                            <label for="payvalue">车辆品牌 *</label>
                            <input
                                id="carInfo"
                                #carInfoInput="ngModel"
                                type="text"
                                name="carInfo"
                                class="form-control"
                                [(ngModel)]="carInfo"
                                required
                            />
                            <validation-messages
                                [formCtrl]="carInfoInput"
                            ></validation-messages>
                        </div>
                        <div class="col-md-12" style="padding-left: 0">
                            <label for="payvalue">车牌颜色 *</label>                           
                            <div class="form-control">                               
                                <label *ngFor="let licenseColor of LicenseColors; let key = index;">
                                    <input type="radio" name="licenseColor" [(ngModel)]="carType" [value]="licenseColor.key" *ngIf="key==0" required  />
                                    <input type="radio" name="licenseColor" [(ngModel)]="carType" [value]="licenseColor.key" *ngIf="key!=0" style="margin-left:20px;" required  />
                                    {{licenseColor.value}}
                                </label>
                            </div>                            
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button
                        [disabled]="saving"
                        type="button"
                        class="btn btn-default"
                        (click)="close()"
                    >
                        {{ l("Cancel") }}
                    </button>
                    <button
                        type="submit"
                        class="btn btn-primary"
                        [disabled]="!editForm.form.valid"
                        [buttonBusy]="saving"
                        [busyText]="l('SavingWithThreeDot')"
                    >
                        <i class="fa fa-save"></i> <span>{{ l("Save") }}</span>
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
